
function ValueGetNumString(num,isPercent,type)
    if num == nil then return "0" end
    local flag = isPercent or false
    if flag then
        if type == 2 then
            return tostring(math.abs(num/10)).."%"
        else
            return tostring(math.abs(num/100)).."%"
        end
    else
        return tostring(math.abs(num))
    end
end

function HaveAttr(id)
    return  HeroAttrInfo.GetHeroAttrData(id) ~= nil
end

function GetAttrString(attrId,attrValue,isPercent)
    if attrId == 0 then return "" end
    local data = HeroAttrInfo.GetHeroAttrData(attrId)
    if data == nil then
        return ""
    else
        local res = ""
        res = res .. (LanModel.GetTextByID(data.nameId) or "")
        if attrValue>=0 and LanModel.GetTextByID(data.plusSignId)~=nil then
            return res ..LanModel.GetTextByID(data.plusSignId)..' '.. ValueGetNumString(attrValue,isPercent or data.numType ~= 0,data.numType)
        elseif attrValue<0 and LanModel.GetTextByID(data.minusSignId)~=nil then
            return res ..LanModel.GetTextByID(data.minusSignId)..' '.. ValueGetNumString(attrValue,isPercent or data.numType ~= 0,data.numType)
        else
            return res .. ValueGetNumString(attrValue,isPercent or data.numType == 1)
        end
    end
end

function GetAttrStringOnlyValue(attrId,attrValue,isPercent)
    if attrId == 0 then return "" end
    local data = HeroAttrInfo.GetHeroAttrData(attrId)
    if data == nil then
        return ""
    else
        if attrValue>=0 and LanModel.GetTextByID(data.plusSignId)~=nil then
            return ValueGetNumString(attrValue,isPercent or data.numType ~= 0,data.numType)
        elseif attrValue<0 and LanModel.GetTextByID(data.minusSignId)~=nil then
            return ValueGetNumString(attrValue,isPercent or data.numType ~= 0,data.numType)
        else
            return ValueGetNumString(attrValue,isPercent or data.numType == 1)
        end
    end
end

function GetAttrOnlyString(attrId,attrValue,percent)
    if attrId == 0 then return "" end
    local data = HeroAttrInfo.GetHeroAttrData(attrId)
    if data == nil then
        return ""
    else
        return ValueGetNumString(attrValue,percent == 1 or data.numType ~= 0,data.numType)
    end
end

function GetAttrNamePro(id,value)
    local flag = value or 0
    local data = HeroAttrInfo.GetHeroAttrData(id)
    if data == nil then
        return ""
    else
        local res = LanModel.GetTextByID(data.nameId) or ""
        if flag >= 0 and LanModel.GetTextByID(data.plusSignId)~=nil then
            return res ..LanModel.GetTextByID(data.plusSignId)
        elseif flag < 0 and LanModel.GetTextByID(data.minusSignId)~=nil then
            return res ..LanModel.GetTextByID(data.minusSignId)
        else
            return res
        end
    end
end

function GetAttrName(id)
    local data = HeroAttrInfo.GetHeroAttrData(id)
    if data == nil then
        return ""
    else
        LanModel.GetTextByID(data.nameId)
    end
end